<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="mytaglib" uri="http://www.baizhi.com/mytaglib" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/styles.css">
</head>
<body>
<div class="divWhiteLine"></div>
<form action="engageSurvey_doEngageSurvey" method="post" >
    <input type="hidden" value="${curPid}" name="curPid"/>
<table>
    <tr>
        <td colspan="2" class="tdWhiteLine"></td>
    </tr>
    <tr>
        <td colspan="2" class="tdHeader">${survey.title }</td>
    </tr>
    <tr>
        <td colspan="2" class="tdWhiteLine"></td>
    </tr>
    <tr>
        <td class="tdSHeaderL">
            ${curPage.title }
        </td>
    </tr>
    <tr>
        <td colspan="2" style="text-align: left;vertical-align: top;">

            <table >
                <tr>
                    <td width="30px"></td>
                    <td width="*">
                        <table>
                                <c:forEach items="${curPage.questionList}" var="question">
                                    <tr>
                                        <td>
                                            <table>
                                                <!-- 迭代问题集合 -->
                                                <tr>
                                                    <!-- 问题题干 -->
                                                    <td class="tdQHeaderL">${question.title}</td>
                                                </tr>
                                                <tr>
                                                    <td colspan="2" style="text-align: left;color: black;background-color: white">
                                                        <!-- 定义变量,设置第一大类的题型 -->
                                                        <c:if test="${question.questiontype lt 4 }">
                                                            <!-- 判断当前题型是否属于第一大类(0,1,2,3) -->
                                                            <c:forEach items="${question.optionArr}" var="option" varStatus="sta">
                                                                <input name="q${question.id}" value="${sta.index}"
                                                                       type="${question.questiontype< 2?'radio':'checkbox' }"
                                                                       <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}" value="${sta.index}">checked</mytaglib:MyTag>
                                                                />${option }
                                                                <c:if test="${question.questiontype == 1 || question.questiontype == 3 }"><br></c:if>
                                                            </c:forEach>

                                                            <!-- 处理other问题 -->
                                                            <c:if test="${question.other==1}">
                                                                <input name="q${question.id}" value="other" type="${question.questiontype< 2?'radio':'checkbox' }"
                                                                       <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}" value="other">checked</mytaglib:MyTag>
                                                                />其他
                                                                <!-- 文本框 -->
                                                                <c:if test="${question.otherstyle == 1}">
                                                                    <input name="q${question.id}other" type="text"
                                                                           value="<mytaglib:MyTag2 curPageId="${curPid}" name="q${question.id}other"/>"
                                                                    />

                                                                </c:if>
                                                                <!--  下拉列表 -->
                                                                <c:if test="${question.otherstyle == 2}">
                                                                    <select name="q${question.id}other">
                                                                        <c:forEach items="${question.otherSelectOptionArr}" var="otheroption" varStatus="sta">
                                                                            <option value="${sta.index}"
                                                                                <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}other" value="${sta.index}">selected</mytaglib:MyTag>
                                                                            >${otheroption }</option>
                                                                        </c:forEach>
                                                                    </select>
                                                                </c:if>
                                                            </c:if>
                                                        </c:if>
                                                        <c:if test="${question.questiontype==4 }">
                                                            <select name="q${question.id}">
                                                                <c:forEach items="${question.optionArr}" var="option" varStatus="sta">
                                                                    <option value="${sta.index}"
                                                                      <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}" value="${sta.index}">selected</mytaglib:MyTag>
                                                                    >${option }</option>
                                                                </c:forEach>
                                                            </select>
                                                        </c:if>
                                                        <c:if test="${question.questiontype==5 }">
                                                            <input type="text" name="q${question.id}" value="<mytaglib:MyTag2 curPageId="${curPid}" name="q${question.id}"/>">
                                                        </c:if>
                                                        <c:if test="${question.questiontype>5 }">
                                                            <table>
                                                                <!-- 列头 -->
                                                                <tr>
                                                                    <td></td>
                                                                    <c:forEach items="${question.matrixColTitleArr}" var="col">
                                                                        <td>${col }</td>
                                                                    </c:forEach>
                                                                </tr>
                                                                <!-- 输出n多行 -->
                                                                <c:forEach items="${question.matrixRowTitleArr}" var="row" varStatus="sta">
                                                                    <tr>
                                                                        <td>${row }</td>
                                                                        <!-- 套打控件 -->
                                                                        <c:forEach items="${question.matrixColTitleArr}" varStatus="colSta">
                                                                            <td>
                                                                                <!-- radio -->
                                                                                <c:if test="${question.questiontype == 6}"><input type="radio" name="q${question.id}_${sta.index}" value="${sta.index}_${colSta.index}" <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}_${sta.index}" value="${sta.index}_${colSta.index}">checked</mytaglib:MyTag>></c:if>
                                                                                <c:if test="${question.questiontype == 7}"><input type="checkbox" name="q${question.id}" value="${sta.index}_${colSta.index}" <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}" value="${sta.index}_${colSta.index}">checked</mytaglib:MyTag>></c:if>
                                                                                <c:if test="${question.questiontype == 8}">
                                                                                    <select name="q${question.id}">
                                                                                        <c:forEach items="${question.matrixSelectOptionArr}" var="so" varStatus="soSta">
                                                                                            <option value="${sta.index}_${colSta.index}_${soSta.index}"
                                                                                                    <mytaglib:MyTag curPageId="${curPid}" name="q${question.id}" value="${sta.index}_${colSta.index}_${soSta.index}">selected</mytaglib:MyTag>
                                                                                            >${so}</option>
                                                                                        </c:forEach>
                                                                                    </select>
                                                                                </c:if>
                                                                            </td>
                                                                        </c:forEach>
                                                                    </tr>
                                                                </c:forEach>
                                                            </table>
                                                        </c:if>
                                                    </td>
                                                </tr>
                                                </table>
                                        </td>
                                    </tr>
                                </c:forEach>

                            </table>
                    </td>
                </tr>
                </table>
        </td>

    </tr>
    <tr>
        <td colspan="2" align="center">
            <!-- 构造上一步按钮 -->
            <c:if test="${curPage.id!=survey.minPageId}">
            <input type="submit" name='submit_pre' value='${sessionScope.survey.pretext}' class="btn">
            </c:if>
            <!-- 构造下一步按钮 -->
            <c:if test="${curPage.id!=survey.maxPageId}">
            <input type="submit" name='submit_next' value='${sessionScope.survey.nexttext}' class="btn">
            </c:if>
            <!-- 构造完成按钮 -->
            <c:if test="${curPage.id==survey.maxPageId}">
            <input type="submit" name="submit_done" value='${sessionScope.survey.donetext}' class="btn">
            </c:if>

            <input type="submit" name="submit_exit" value='${sessionScope.survey.exittext}' class="btn">
        </td>
    </tr>
    </table>
</form>
</body>
</html>
